<?
function drizzo_get_post_id($post_permalink) {
	drizzo_db_connect();
	global $drizzo_posts;
	$post_id_lookup = @mysql_query("SELECT `ID` FROM `$drizzo_posts` WHERE `permalink_name`='$post_permalink'");
	if(!mysql_errno()) {
		$post_id = @mysql_fetch_assoc($post_id_lookup);
		$post_id = $post_id['ID'];
	} else {
		$post_id = false;
	}
	return $post_id;
}

function drizzo_get_the_post($query_id = 0) {
	drizzo_db_connect();

	global $drizzo_posts, $drizzo_post_id, $drizzo_comments;
	
	$post_query = @mysql_query("SELECT * FROM `$drizzo_posts` WHERE `ID`='$query_id' LIMIT 1");
	if(mysql_errno()) {
		return false;
	} else {
		while($row = @mysql_fetch_assoc($post_query)) {
			$author = drizzo_user_info($row['author'],'display_name');
			$time = drizzo_global_options('time_format');
			foreach($row as $field => $value) {
				if($field != 'posted_date' && $field != 'edited_date') {
					$the_post[$field] = drizzo_db_unwrap($value);
				}
			}
			if(drizzo_global_options("post_eval_" . $row['ID']) == 1) {
				$the_post['content'] = $row['content'];
			}
			$the_post['author_display_name'] = $author;
			$the_post['comment_count'] = strval(drizzo_comment_count($row['ID']));
			$the_post['posted_date'] = gmdate($time, drizzo_timezone_offset($row['posted_date']));
			$the_post['posted_date_raw'] = $row['posted_date'];
			$the_post['edited_date'] = gmdate($time, drizzo_timezone_offset($row['edited_date']));
			$the_post['edited_date_raw'] = $row['edited_date'];

			return $the_post;

		}
	}
}

function drizzo_get_the_posts($limit = null, $offset = null, $status = "publish", $types = "blog,aside") {
	global $drizzo_posts, $drizzo_comments, $drizzo_users, $drizzo_limit, $drizzo_offset;

	if(!$limit) {
		$limit = $drizzo_limit;
	}
	if($offset == null && $drizzo_offset) {
		$offset = $drizzo_offset;
	} elseif($offset == null) {
		$offset = 0;
	} else {
	}
	
	$statuses = explode(",", $status);
	for($i =0; $i < count($statuses); $i++) {
		if($i < (count($statuses) -1)) {
			$status_string .= "'" . $statuses[$i] . "', ";
		} else {
			$status_string .= "'" . $statuses[$i] . "'";
		}
	}
	
	$status = $status_string;

	$type_list = explode(",", $types);
	for($i =0; $i < count($type_list); $i++) {
		if($i < (count($type_list) -1)) {
			$type_string .= "'" . $type_list[$i] . "', ";
		} else {
			$type_string .= "'" . $type_list[$i] . "'";
		}
	}
	
	$types = $type_string;
	
	drizzo_db_connect();

	if($limit == 0) {
		$the_posts_query = @mysql_query("SELECT * FROM `$drizzo_posts` WHERE `status` IN ($status) AND `type` IN ($types) ORDER BY `ID` DESC");
	} else {
		$the_posts_query = @mysql_query("SELECT * FROM `$drizzo_posts` WHERE `status` IN ($status) AND `type` IN ($types) ORDER BY `ID` DESC LIMIT $offset,$limit");
	}

	if(mysql_errno()) {
		return false;
	} else {
		while($row = @mysql_fetch_assoc($the_posts_query)) {
			$author = drizzo_user_info($row['author'],'display_name');
			$time = drizzo_global_options('time_format');
			foreach($row as $field => $value) {
				if($field != 'posted_date' && $field != 'edited_date') {
					$the_posts[$i][$field] = drizzo_db_unwrap($value);
				}
			}
			if(drizzo_global_options("post_eval_" . $row['ID']) == 1) {
				$the_post['content'] = $row['content'];
			}
			$the_posts[$i]['author_display_name'] = $author;
			$the_posts[$i]['comment_count'] = strval(drizzo_comment_count($row['ID']));
			$the_posts[$i]['posted_date'] = gmdate($time, drizzo_timezone_offset($row['posted_date']));
			$the_posts[$i]['posted_date_raw'] = $row['posted_date'];
			$the_posts[$i]['edited_date'] = gmdate($time, drizzo_timezone_offset($row['edited_date']));
			$the_posts[$i]['edited_date_raw'] = $row['edited_date'];
			$i++;				
		}
	}
	return $the_posts;
}

function drizzo_get_the_asides($limit = 1) {
	$the_posts = drizzo_get_the_posts($limit, 0, "publish", "aside");
	return $the_posts;
}

function drizzo_asides($limit = 1) {
	$the_posts = drizzo_get_the_asides($limit);
	$asides_string .= "<ul id=\"asides\">\n";
	if(count($the_posts) > 0) {
		foreach($the_posts as $the_post) {
			$asides_string .= "\t<li class=\"aside\"><strong>" . $the_post['title'] . "</strong><br />" . $the_post['content'] . "</li>\n";
		}

	} else {
		$asides_string .= "<li>There are no asides.</li>\n";
	}
	$asides_string .= "</ul>\n";
	return $asides_string;
}

function drizzo_post_id() {
	global $the_post;

	$id= "";
	
	if(!$the_post) {
		return false;
	} else {
		$id = $the_post['ID'];
		return $id;
	}
}

function drizzo_post_title() {
	global $the_post;
	
	$title= "";
	
	if(!$the_post) {
		return false;
	} else {
		$title = $the_post['title'];
		return $title;
	}
}

function drizzo_page_menu_name($id = null) {
	global $the_post;
	if($id) {
		$this_post = drizzo_get_the_post($id);
		return $this_post['menu_name'];
	} elseif($the_post) {
		return $the_post['menu_name'];
	} else {
		return false;
	}
}

function drizzo_author_info($var = "ID", $id = null) {
	if(!$id) {
		global $the_post;
		$id = $the_post['author'];
	}
	return drizzo_user_info($id,$var);
}

function drizzo_post_author($var = "ID", $id = null) {
	if(!$id) {
		global $the_post;
		$id = $the_post['author'];
	}
	return drizzo_user_info($id,$var);
}

function drizzo_post_status($id = null) {
	global $the_post;
	
	if($id) {
		$the_post = drizzo_get_the_post($id);
	}
	
	if(!$the_post) {
		return false;
	} else {
		return $the_post['status'];;
	}
}

function drizzo_page_order($id = null) {
	return drizzo_post_order($id);
}

function drizzo_post_order($id = null) {
	global $the_post;

	if($id) {
		$the_post = drizzo_get_the_post($id);
	}
	
	if((!$the_post) || ($the_post['type'] != "page")) {
		return false;
	} else {
		return $the_post['page_order'];
	}
}

function drizzo_post_content($length = null, $word_count = 150) {
	global $the_post;
	
	$content = "";
	$excerpt = "";
	
	if(!$the_post) {
		return false;
	} else {
		$content = $the_post['content'];
		
		if(!$length || ($length == "excerpt" && str_word_count($content) <= $word_count)) {
			if(drizzo_global_options("post_eval_" . $the_post['ID']) == 1) {
				eval("?>" . $content);
			} else {
				return drizzo_texturize($content);
			}
		}
		
		if($length == "excerpt" && str_word_count($content) > $word_count) {
			$excerpt = strip_tags($content,'<br />,<pre>,<code>,<blockquote>,<p>');
			$excerpt = explode(" ", $excerpt);
			for($i = 0; $i < $word_count; $i++) {
				$content_string .= $excerpt[$i] . " ";
			}
			$content_string .= "<p><a href=\"" . drizzo_post_permalink() . "\">Read on...</a></p>";
			return $content_string;
		}
	}
}

function drizzo_post_content_backend() {
	global $the_post;
	return $the_post['content'];
}

function drizzo_post_excerpt($word_count = 150) {
	$excerpt = drizzo_post_content("excerpt", $word_count);
	return $excerpt;
}

function drizzo_post_date($var = "all") {
	return drizzo_post_time($var);
}

function drizzo_timezone_offset($timestamp) {
	if(isset($_COOKIE['drizzo_timezone'])) {
		$offset = ($_COOKIE['drizzo_timezone'] * 60 * 60);
	} else {
		$offset = (drizzo_global_options('timezone_offset') + date('I')) * 60 * 60;
	}
	return $timestamp + $offset;
}

function drizzo_post_time($var = "all") {
	global $the_post;
	
	if(!$the_post) {
		$date = false;
	} else {
		$date = drizzo_timezone_offset($the_post['posted_date_raw']);
		if($var == "all") {
			$date = $the_post['posted_date'];
		} elseif($var == "year") {
			$date = gmdate("Y", $date);
		} elseif($var == "month") {
			$date = gmdate("m", $date);
		} elseif($var == "date") {
			$date = gmdate("d", $date);
		} elseif($var == "day") {
			$date = gmdate("l", $date);
		} elseif($var == "hour") {
			$date = gmdate("h", $date);
		} elseif($var == "hour_24") {
			$date = gmdate("H", $date);
		} elseif(($var == "minutes") || ($var == "minute")) {
			$date = gmdate("m", $date);
		} elseif($var == "seconds") {
			$date = gmdate("s", $date);
		} elseif($var == "raw") {
			$date = $the_post['posted_date_raw'];
		} else {
			$date = gmdate($var, $date);
		}
	}
	return $date;
}

function drizzo_post_edit_date($var = "all") {
	global $the_post;
	
	$edit_date = "";
	
	if(!$the_post) {
		$date = false;
	} else {
		$date = drizzo_timezone_offset($the_post['edited_date_raw']);
		if($var == "all") {
			$date = $the_post['edited_date'];
		} elseif($var == "year") {
			$date = gmdate("Y", $date);
		} elseif($var == "month") {
			$date = gmdate("m", $date);
		} elseif($var == "date") {
			$date = gmdate("d", $date);
		} elseif($var == "day") {
			$date = gmdate("l", $date);
		} elseif($var == "hour") {
			$date = gmdate("h", $date);
		} elseif($var == "hour_24") {
			$date = gmdate("H", $date);
		} elseif(($var == "minutes") || ($var == "minute")) {
			$date = gmdate("m", $date);
		} elseif($var == "seconds") {
			$date = gmdate("s", $date);
		} elseif($var == "raw") {
			$date = $the_post['edited_date_raw'];
		} else {
			$date = gmdate($var, $date);
		}
	}
	return $date;
}

function drizzo_post_editor($var = "ID", $id = null) {
	global $the_post;
	
	if($id != null) {
		$the_post = drizzo_get_the_post($id);
	}
	return drizzo_user_info($the_post['edited_by'],$var);
}

function drizzo_post_tags($id = null, $style = "comma", $links = "true") {
	global $drizzo_posts, $the_post;
	
	drizzo_db_connect();
	
	if($id == null && empty($the_post)) {
		return false;
	} else {
		if($id > 0) {
			$the_post = drizzo_get_the_post($id);
		}

		$tags = explode(", ", $the_post['tags']);
		$tags_lower = array_map('strtolower', $tags);
		array_multisort($tags_lower, SORT_ASC, SORT_STRING, $tags);

		if($style == "comma") {
				$tag_count = 1;
				$tags_string = null;
				foreach($tags as $tag) {
					$tag_nice = str_replace("-", " ", $tag);
					if($links == "true") {
						if($tag_count < count($tags)) {
							$tags_string .= "<a href=\"/tags/" . $tag . "\">" . $tag_nice . "</a>, ";
						} else {
							$tags_string .= "<a href=\"/tags/" . $tag . "\">" . $tag_nice . "</a>";
						}
					} else {
						if($tag_count < count($tags)) {
							$tags_string .= $tag_nice . ", ";
						} else {
							$tags_string .= $tag_nice;
						}
					}
					$tag_count++;
				}

			return $tags_string;
		}
		
		if($style == ("list" || "ul" || "ol")) {
			if($style == ("list" || "ul")) { $list_type = "ul"; }
			if($style ==("ol")) { $list_type = "ol"; }
			
			$tags_query = @mysql_query("SELECT `tags` FROM `$drizzo_posts` WHERE `ID`='$id'");
			if(!mysql_errno()) {
				while($row = @mysql_fetch_assoc($tags_query)) {
					$tags = $row['tags'];
				}
				$tag = explode(", ", $tags);
				$tag_lower = array_map('strtolower', $tag);
				array_multisort($tag_lower, SORT_ASC, SORT_STRING, $tag);
				$tag_count = count($tag);
				$tags_string .= "<" . $list_type . " id=\"tags-list\">\n";
					for($no = 0; $no < $tag_count; $no++) {
						if($links == "true") {
							$tag_nice[$no] = preg_replace("/-/", " ", $tag[$no]);
							$tags_string .= "\t<li class=\"tag\"><a href=\"/tags/" . $tag[$no] . "\">" . $tag_nice[$no] . "</a></li>\n";
						} else {
							$tag_nice[$no] = preg_replace("/-/", " ", $tag[$no]);
							$tags_string .= "\t<li class=\"tag\">" . $tag[$no] . "</li>\n";
						}
					}
				$tags_string .= "</" . $list_type . ">\n";

				return $tags_string;
			} else {
				return false;
			}
		}
	}
}

function drizzo_post_permalink($id = null) {
	global $the_post, $the_posts;
	
	if($id != null) {
		$the_post = drizzo_get_the_post($id);
	}
	
	drizzo_db_connect();
	
	if(!$the_post) {
		return false;
	} else {
		$use_permalinks = drizzo_global_options('use_permalinks');
		if($use_permalinks == 0) {
			$the_permalink = domain . "?view=" . $the_post['ID'];
		} else {
			if($the_post['type'] == 'page') {
				$the_permalink = domain . drizzo_page_permalink($the_post['ID'],null);
			} else {
				$the_permalink = domain . $the_post['type'] . "/" . $the_post['permalink_name'] . "/";
			}
		}
		return $the_permalink;
	}
}

function drizzo_page_ancestor($id = null) {
	if($id == null) {
		global $drizzo_post_id;
		$id = $drizzo_post_id;
	}
	$ancestor = drizzo_page_parent($id);
	if(drizzo_page_parent($ancestor) > 0) {
		drizzo_page_parent($ancestor);
	} else {
		return $ancestor;
	}
}

function drizzo_page_parent($id) {
	global $drizzo_posts;
	$parent_lookup = @mysql_query("SELECT `page_parent` FROM `$drizzo_posts` WHERE `ID`='$id'");
	if(!mysql_errno()) {
		while($row = @mysql_fetch_assoc($parent_lookup)) {
			$parent = $row['page_parent'];
		}
	} else {
		$parent = false;
	}
	return $parent;
}

function drizzo_page_children($id) {
	global $drizzo_posts;
	$children_lookup = @mysql_query("SELECT `ID` FROM `$drizzo_posts` WHERE `page_parent`='$id' AND `type` IN ('page')");
	if(!mysql_errno()) {
		while($row = @mysql_fetch_assoc($children_lookup)) {
			$children[] = $row['ID'];
		}
	} else {
		$children = false;
	}
	return $children;
}

function drizzo_page_permalink($id = null, $permalink = null) {
	global $the_post, $drizzo_posts;
	if($id != null) {
		$this_post = drizzo_get_the_post($id);
	} elseif($id == null && !empty($the_post)) {
		$this_post = $the_post;
	}

	if($this_post['page_parent'] > 0) { // If the page has a parent
		if($permalink == null) { // If this function is looping through for the first time
			$permalink = $this_post['permalink_name'] . "/";
		} else { // If this function is looping
			$permalink = $this_post['permalink_name'] . "/" . $permalink;
		}		
		$permalink = drizzo_page_permalink($this_post['page_parent'],$permalink);
	} else { // If the page is top level
		if($permalink == null) { // If this function is looping through for the first time
			$permalink = $this_post['permalink_name'] . "/";
		} else { // If this function is looping
			$permalink = $this_post['permalink_name'] . "/" . $permalink;
		}
	}
	return $permalink;
}

function drizzo_related_pages($depth = 5) {
	global $drizzo_post_id;
	if($drizzo_post_id) {
		$this_post = drizzo_get_the_post($drizzo_post_id);
		if($this_post['page_parent'] == 0) {
			return drizzo_pages($drizzo_post_id, $depth);
		} else {
			return drizzo_pages(drizzo_page_ancestor($drizzo_post_id), $depth);
		}
	} else {
		return false;
	}
}

function drizzo_pages($parent = null, $depth = 0, $exclude = null) {
	global $drizzo_posts, $the_post;
	if($parent < 0 || drizzo_pages_loop($parent, $depth, 0, $exclude) == false) {
		$pages = false;
	} else {
		$pages = drizzo_pages_loop($parent, $depth, 0, $exclude);

		$pages = "<ul class=\"pages_list\">\n" . $pages . "</ul>\n";
	}
	
	return $pages;
}

function drizzo_pages_loop($parent = null, $depth = 0, $sub_no = 0, $exclude = null) {
		$children = drizzo_page_children($parent);
		if($children) {
			foreach($children as $child) {
				if(is_array($exclude) && array_search($child, $exclude)) {
					break;
				} elseif($child == $exclude) {
					break;
				} else {
					$this_post = drizzo_get_the_post($child);
					$pages .= "<li id=\"" . $this_post['permalink_name'] . "\"";
					if(substr_count("http://" . $_SERVER[HTTP_HOST] . $_SERVER['REQUEST_URI'],drizzo_post_permalink($child)) > 0) {
						$pages .= " class=\"current sub$sub_no\"";
					} else {
						$pages .= " class=\"sub$sub_no\"";
					}
					$pages .= "><a href=\"" . drizzo_post_permalink($child) . "\" title=\"" . drizzo_post_title($child) . "\"><span>" . drizzo_page_menu_name($child) . "</span></a></li>\n";
					if($sub_no < $depth) {
						if(drizzo_page_children($child)) {
							$sub_no++;
							$pages .= drizzo_pages_loop($child, $depth, $sub_no, $exclude);
						}
					}
				}
			}
		}
	return $pages;
}

function drizzo_last_post_date() {
	global $drizzo_posts;
	
	drizzo_db_connect();
	
	$now = time();
	
	$lookup = @mysql_query("SELECT `posted_date` FROM `$drizzo_posts` WHERE `posted_date`<'$now' ORDER BY `posted_date` LIMIT 1");
	if(!mysql_errno()) {
		$last_date = @mysql_fetch_assoc($lookup);
		$last_date = $last_date['posted_date'];
		return $last_date;
	} else {
		return false;
	}
}

function drizzo_get_post_filters() {
	global $drizzo_options;
	
	$filters_query = @mysql_query("SELECT `value` FROM `$drizzo_options` WHERE `name`='post_filters'");
	if(!mysql_errno()) {
		while($row = @mysql_fetch_assoc($filters_query)) {
			$filters[] = $row['value'];
		}
		if(count($filters) > 0) {
			return $filters;
		} else {
			return false;
		}
	} else {
		return false;
	}
}

function drizzo_post_filters($text) {
	if(drizzo_get_post_filters())  {
		$filters = drizzo_get_post_filters();
		foreach($filters as $filter) {
			if(function_exists($filter)) {
				$text = $filter($text);
			}
		}
	}
	return $text;
}

function drizzo_texturize($text) {
	require_once('markdown.php');
	require_once('smartypants.php');
	$text = Markdown($text);
	if(drizzo_global_options('smartypants')) {
		$text = SmartyPants($text);
	}
	if(drizzo_global_options('autolinks')) {
		$text = drizzo_autolinks($text);
	}
	
	$text = drizzo_post_filters($text);
	
	return $text;
}

function drizzo_autolinks($text) {
	global $drizzo_links;
	$case_sensitive = drizzo_global_options('autolinks_case_sensitive');
	$all_links = drizzo_global_options('autolinks_all');
	if(!preg_match("'<!--autolink off-->'",$text)) {
		$links_lookup = @mysql_query("SELECT `name`,`url` FROM `$drizzo_links` ORDER BY `name`");
		if(!mysql_errno()) {
			while($row = @mysql_fetch_assoc($links_lookup)) {
				$links[] = array(
						"title" => $row['name'],
						"url" => $row['url']
					);
			}
			foreach($links as $link) {
				if($all_links) {
					if($case_sensitive) {
						$text = preg_replace("/( |\(|<p>|&#8220;|&#8216;)($link[title])( |.|\)|<\/p>|&#8221;|&#8217;)+/", "\\1<a href=\"$link[url]\" title=\"$link[title]\">\\2</a>\\3", $text);
					} else {
						$text = preg_replace("/( |\(|<p>|&#8220;|&#8216;)($link[title])( |.|\)|<\/p>|&#8221;|&#8217;)/i", "\\1<a href=\"$link[url]\" title=\"$link[title]\">\\2</a>\\3", $text);
					}
				} else {
					if($case_sensitive) {
						$first_link = substr($text,strpos($link['title'],$text),strlen($link['title']));
						$first_url = "<a href=\"$link[url]\" title=\"$link[title]\">$link[title]</a>";
						$text = preg_replace("/( |\(|<p>|&#8220;|&#8216;)($link[title])( |.|\)|<\/p>|&#8221;|&#8217;)/", "\\1<a href=\"$link[url]\" title=\"$link[title]\">\\2</a>\\3", $text);
					} else {
						$text = preg_replace("/( |\(|<p>|&#8220;|&#8216;)($link[title])( |.|\)|<\/p>|&#8221;|&#8217;)/i", "\\1<a href=\"$link[url]\" title=\"$link[title]\">\\2</a>\\3", $text);
					}
				}
			}
		}
	}

// Look for the {{}} autolink escapers and remove them
	$text = preg_replace('/\{\{([\w]+)\}\}/', "\\1", $text);

	return $text;
}

function drizzo_permalink_check($permalink_name, $id) {
	$lookup = drizzo_permalink_check_loop($permalink_name, $id);
	if($lookup == false || $_POST['old_permalink_name'] == $permalink_name) {
		return $permalink_name;
	} else {
		$i = 1;
		while(drizzo_permalink_check_loop($permalink_name . "-" . $i, $id) >= 0) {
			if(drizzo_permalink_check_loop($permalink_name . "-" . $i, $id) == 0) {
				return $permalink_name . "-" . $i;
			}
			$i++;
		}
	}
}

function drizzo_permalink_check_loop($permalink_name, $id) {
	global $drizzo_posts;
	if($permalink_name == 'drizzo') {
		return false;
	}
	drizzo_db_connect();
	$permalink_lookup = @mysql_query("SELECT `permalink_name` FROM `$drizzo_posts` WHERE `permalink_name`='$permalink_name' AND `ID`!='$id'");
	if(@mysql_num_rows($permalink_lookup) > 0) {
		return @mysql_num_rows($permalink_lookup);	
	} else {
		return false;
	}
}

function drizzo_post_save() {
	global $edit, $drizzo_posts;
	$edited_time = time();
	if(drizzo_global_options('warehouse_use') == "1" && $_POST['ID']) {
		drizzo_move_to_warehouse($_POST['ID'], $edited_time);
	}
	
	$_POST = drizzo_db_wrap($_POST);
	extract($_POST);
	$tags = drizzo_parse_the_tags($tags);
	if(isset($posted_date)) {
		$date = $posted_date;
	} else {
		$date = gmmktime($date_hour,$date_min,$date_secs,$date_month,$date_day,$date_year);
	}
	$permalink_name = ereg_replace("[^(A-Za-z0-9)|-]", "", strtolower(preg_replace("/ /", "-", $permalink_name)));
	if($permalink_name == "" || $permalink_name == null) { $permalink_name = ereg_replace("[^(A-Za-z0-9)|-]", "", strtolower(preg_replace("/ /", "-", $title))); }
	$permalink_name = drizzo_permalink_check($permalink_name, $ID);
	if(strlen($menu_name) <= 0 && $type == 'page') {
		$menu_name = $title;
	}
	$edited_by = session_user_id;

	drizzo_db_connect();
	
	if($_GET['action'] == "publish") {
		$status = "publish";
		$author = session_user_id;
	}

	if(($edit_submit || $_GET['action'] == 'continue' || $_GET['edit'] > 0) && $_GET['action'] != 'continue_new') {
		$update_sql = @mysql_query("UPDATE `$drizzo_posts` SET `title`='$title',`content`='$content',`tags`='$tags',`posted_date`='$date',`author`='$author',`type`='$type',`status`='$status',`comment_status`='$comment_status',`page_parent`='$page_parent',`menu_name`='$menu_name',`page_order`='$page_order',`permalink_name`='$permalink_name',`edited_date`='$edited_time',`edited_by`='$edited_by' WHERE `ID`='$ID'");
		if(!mysql_errno()) {
			if(isset($eval_content)) {
				drizzo_update_options('post_eval_' . $ID,$eval_content);
			}
			drizzo_cache_destroy(drizzo_post_permalink($ID));
			return true;
		} else {
			return false;
		}
	} elseif($new_submit || $_GET['action'] == 'continue_new') {
		$insert_sql = @mysql_query("INSERT INTO `$drizzo_posts` SET `title`='$title',`content`='$content',`tags`='$tags',`posted_date`='$date',`author`='$author',`type`='$type',`status`='$status',`comment_status`='$comment_status',`page_parent`='$page_parent',`menu_name`='$menu_name',`page_order`='$page_order',`permalink_name`='$permalink_name',`edited_date`='$edited_time',`edited_by`='$edited_by'");
		if(!mysql_errno()) {
			if(isset($eval_content)) {
				drizzo_update_options('post_eval_' . mysql_insert_id(),$eval_content);
			}
			return mysql_insert_id();
		} else {
			return false;
		}
	} else {
		return false;
	}
	
	
}
?>
